package se.rende.myrss.data;

import java.io.IOException;
import java.io.InputStream;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.ccil.cowan.tagsoup.Parser;
import org.jdom.JDOMException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class TestXsl {
	public static void main(String[] args) throws JDOMException, IOException, TransformerException, SAXException {
		StreamSource sheet = new StreamSource(TestXsl.class.getResourceAsStream("format-comment.xsl"));
		TransformerFactory factory = TransformerFactory.newInstance();
		Transformer transformer = factory.newTransformer(sheet);

		Parser reader = new Parser();
//		InputStream is = new URL("http://rss.slashdot.org/~r/Slashdot/slashdot/~3/skMUDygbzYc/the-motivated-rejection-of-science").openStream();
		InputStream is = TestXsl.class.getResourceAsStream("sample1.html");
		SAXSource source = new SAXSource(reader, new InputSource(is));
		
		StreamResult result = new StreamResult(System.out);

		transformer.transform(source, result);
	}
}
